/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package tests.acceptenceTests;

import exception.LoggedInException;
import exception.NoPermissionException;
import exception.NotLoggedInException;
import java.rmi.RemoteException;
import java.sql.SQLException;

import server.ForumHandler;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;

/**
 *
 * @author iziko
 */
public class AddForumTest {

    static ForumHandler fh;

    public AddForumTest() {
    }

    @BeforeClass
    public static void setUpClass() throws Exception {
    	fh = new ForumHandler();
	    fh.removeUser(12357911,"iziko128");
	    fh.register("iziko128", "1986", 1, "zi@mail", "izik", "orgad");
	    fh.login("iziko128", "1986");
	    try{
	    	fh.login("yuripo", "1");
	    }catch (LoggedInException e){}
    }

    @AfterClass
    public static void tearDownClass() throws Exception {
    	fh.logout("iziko128","1986");
    	fh.removeUser(12357911,"iziko128");
    	fh.logout("yuripo","1");
    }

    @Before
    public void setUp() throws RemoteException, Exception {
    }

    @After
    public void tearDown() {
    }

    // TODO add test methods here.
    // The methods must be annotated with annotation @Test. For example:
    //
    @Test
     public void testAddNewForum() throws NotLoggedInException, NoPermissionException {
        try {
			fh.createForum("yuripo", "1", "food");
		
        assertEquals("food",fh.getForumList("yuripo", "1").getFirst().getName());
        } catch (SQLException e) {
			System.out.println("SHOULDN'T OF GOT HERE!!! TEST AGAIN!");
        }
        
    }
    
    @Test (expected = NoPermissionException.class)
    public void testAddNewForumForbiden() throws NotLoggedInException, NoPermissionException {
       try {
			fh.createForum("iziko128", "1986", "food");
		
       assertEquals("food",fh.getForumList("iziko128", "1986").getFirst().getName());
       } catch (SQLException e) {
			System.out.println("SHOULDN'T OF GOT HERE!!! TEST AGAIN!");
       }
       
   }

}